namespace cnVery.bbs.UI.UserControls
{
    using cnVery.bbs.Entity;
    using cnVery.Utils;
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;

    public class UserPanel : UserControl
    {
        private string _username;

        public UserPanel()
        {
            User user = new User();
            if (user.IsGuest)
            {
                this.Visible = false;
            }
            else
            {
                this._username = user.Name;
            }
        }

        private void InitializeComponent()
        {
            base.Load += new EventHandler(this.Page_Load);
        }

        protected override void OnInit(EventArgs e)
        {
            this.InitializeComponent();
            base.OnInit(e);
        }

        private void Page_Load(object sender, EventArgs e)
        {
            string str = Fetch.CurrentUrl.ToLower();
            string[] strArray = new string[] { "/user_alter.aspx", "/message_", "/user_upface.aspx" };
            string[] strArray2 = new string[] { "modifiercell", "messagecell", "upfacecell" };
            for (int i = 0; i < strArray.Length; i++)
            {
                if (str.IndexOf(strArray[i]) != -1)
                {
                    HtmlTableCell cell = this.FindControl(strArray2[i]) as HtmlTableCell;
                    if (cell != null)
                    {
                        cell.Attributes.Add("class", "bg1");
                        break;
                    }
                }
            }
        }

        protected string timerange
        {
            get
            {
                DateTime now = DateTime.Now;
                return ("&time1=" + now.AddMonths(-2).ToString("d") + "&time2=" + now.ToString("d"));
            }
        }

        protected string username
        {
            get
            {
                return base.Server.UrlEncode(this._username);
            }
        }
    }
}

